import React, { Component } from "react"
import PropTypes from "prop-types"

export class Header extends Component {
    // 从 ES2022 开始，你也可以在 React 类组件中将 defaultProps 声明为静态属性
    /* static defaultProps = {
        headerList: [{ title: "默认标题1" }, { title: "默认标题2" }, { title: "默认标题3" }],
    } */
    render() {
        const { headerList } = this.props
        console.log(headerList)
        return (
            <>
                <div>Header </div>
                {headerList.map((item) => (
                    <li alt={item.title} key={item.title}>
                        {item.title}
                    </li>
                ))}
            </>
        )
    }
}

Header.propTypes = {
    headerList: PropTypes.array.isRequired,
}
Header.defaultProps = {
    headerList: [{ title: "默认标题1" }, { title: "默认标题2" }, { title: "默认标题3" }],
}

export default Header
